<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>修改密码</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="修改,密码">
	<meta http-equiv="description" content="This is my page">

  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="" namespace="">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'修改密码'}]"/>
    			<jsp:param name="width" value="70%"/>
    		</jsp:include>
    		
    		<table width="100%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr bgcolor="#FFFFFF">
    				<td width="30%" align="right" class="label">
    					原密码：
    					<br>
    					<font color="red">(16字以内)</font>
    				</td>
    				<td width="70%" align="left">
    					<s:password name="uvo.beforePassword" id="beforePassword" cssStyle="width:95%" maxlength="16"></s:password>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					新密码：
    					<br>
    					<font color="red">(16字以内)</font>
    				</td>
    				<td align="left">
    					<s:password name="user.password" id="password" cssStyle="width:95%" maxlength="16"></s:password>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					确认码：
    					<br>
    					<font color="red">(16字以内)</font>
    				</td>
    				<td align="left">
    					<s:password id="ensurePassword" cssStyle="width:95%" maxlength="16"></s:password>
    				</td>
    			</tr>
    		</table>
    		
    		<table width="100%" cellspacing="0">
    			<tr>
    				<td align="center" valign="bottom" height="30">
    					<input type="button" value="修改" class="btn" onclick="updatePassword()" />
    				</td>
    			</tr>
    		</table>
    		
    		
    	</s:form>
    </center>
    
    <script type="text/javascript">
    function updatePassword()
    {
    	var beforePassword = $('#beforePassword');
    	var password = $('#password');
    	var ensurePassword = $('#ensurePassword');
    	if('' == beforePassword.val().Trim())
    	{
    		showMsg('原密码不能为空。', function(){beforePassword.focus();});
    		return;
    	}
    	if('' == password.val().Trim())
    	{
    		showMsg('新密码不能为空。', function(){password.focus();});
    		return;
    	}
    	if('' == ensurePassword.val().Trim())
    	{
    		showMsg('确认密码不能为空。', function(){ensurePassword.focus();});
    		return;
    	}
    	if(password.val().Trim() != ensurePassword.val().Trim())
    	{
    		showMsg('密码与确认密码必须相同。', function(){ensurePassword.focus();});
    		return;
    	}
    	$.ajax({
    		url:'${CONTEXT_PATH}/inner/user/updatePassword.action',
    		type:'post',
    		data:$("#frm").serialize(),
    		dataType:'json',
    		success:
    			function(result){
   					if(result == true)
   					{
   						showMsg('修改成功。', function(){
		    				window.close();
				    	});
		    		}
		    		else
		    		{
		    			showMsg('修改失败，原密码不正确。');
		    		}
    			}
    	});
    }
    </script>
  </body>
</html>
